package com.chandra.pos.util;

import com.chandra.pos.dao.entity.CustomerEntity;
import org.hibernate.search.indexes.interceptor.EntityIndexingInterceptor;
import org.hibernate.search.indexes.interceptor.IndexingOverride;

/**
 * Created by IntelliJ IDEA.
 * User: root
 * Date: 7/4/12
 * Time: 1:40 AM
 * To change this template use File | Settings | File Templates.
 */
public class IndexWhenCustomerInterceptor implements EntityIndexingInterceptor<CustomerEntity> {
    @Override
    public IndexingOverride onAdd(CustomerEntity customerEntity) {
        if (customerEntity.isSupplier()) {
            return IndexingOverride.APPLY_DEFAULT;
        }
        return IndexingOverride.SKIP; //To change body of implemented methods use File | Settings | File Templates.
    }


    @Override
    public IndexingOverride onUpdate(CustomerEntity customerEntity) {
        if (customerEntity.isSupplier()) {
            return IndexingOverride.APPLY_DEFAULT;
        }
        return IndexingOverride.SKIP;//To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public IndexingOverride onDelete(CustomerEntity customerEntity) {
        return IndexingOverride.APPLY_DEFAULT;
    }

    @Override
    public IndexingOverride onCollectionUpdate(CustomerEntity customerEntity) {
        return onUpdate(customerEntity);
    }
}
